import numpy as np
import torch
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.types import NVARCHAR, Float, Integer,BigInteger

# 产生线性随机资料100笔，介于 0-50
n = 100
X = np.linspace(0, 50, n)
y = np.linspace(0, 50, n)
XX = np.linspace(0, 50, n)
yy = np.linspace(0, 50, n)

yy += np.random.uniform(-10, 10, n)
# 资料加一点杂讯(noise)
X += np.random.uniform(-10, 10, n)
y += np.random.uniform(-10, 10, n)

df = pd.DataFrame({"x":XX,"label":yy})
df = df.reset_index(drop=True)
print(df)
#
# from sqlalchemy import create_engine
#
# DTYPES = {'x' : BigInteger, 'label':BigInteger}
#
engine = create_engine("mysql+mysqldb://un:password@app1:3306/spring_cloud_alibaba_practice")
# #
df.to_sql(name="data", con=engine,if_exists='append',index=False)



